package com.lagou.edu.servlet;

import com.lagou.edu.pojo.Request;
import com.lagou.edu.pojo.Response;

/**
 * @ClassName: HttpServlet
 * @Auther: Jerry
 * @Date: 2020/7/31 23:09
 * @Desctiption: TODO
 * @Version: 1.0
 */
public abstract class HttpServlet implements Servlet {

    protected abstract void doGet(Request request, Response response) throws Exception;

    protected abstract void doPost(Request request, Response response) throws Exception;

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destroy() throws Exception {

    }

    @Override
    public void service(Request request, Response response) throws Exception {
        if ("GET".equalsIgnoreCase(request.getMethod())) {
            this.doGet(request, response);
        } else {
            this.doPost(request, response);
        }
    }
}
